/***************************************************************************
创建者：　华磊
 开始时间：               : 2020.1１.０1
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   程序运行视窗测试用代理类
*                                                                         *
 ***************************************************************************/
#ifndef RUNDELEGATE_H
#define RUNDELEGATE_H

#include "rundelegate_global.h"
#include <QDialog>
#include <QObject>
//#include <QDebug>
#include <QStringList>
#include "../RunView/runview.h"
#include "../CommunicateDelegate/moveoperation.h"

extern FileData fileData;
class ProgramLanguageTranslate;
class CommunicateNormalDelegate;

/**
 * @brief The RunDelegate class    程序运行视窗测试用代理类
 */
class RUNDELEGATESHARED_EXPORT RunDelegate : public QObject
{
    Q_OBJECT

public:
    RunDelegate(CommunicateNormalDelegate *communicateNormalIn, RunView *runViewIn,
                GlobalData *globalDataIn,GlobalData *ioDataIn,MoveOperation *moveOperationIn,
                ProgramLanguageTranslate *programLanguageTranslateIn,QObject* parent=0);
    ~RunDelegate();

    void initConnect();                 //初始哈connnect

    /**
     * @brief initialView               初始化界面函数
     */
    //void initialView();

    bool openFileAndCreateList(QString fileName);

    /**
     * @brief getRrgToIndex             获取R寄存的数值
     * @param arg1
     * @return
     */
    int getRrgToIndex(QString arg1);


signals:
    void runningProgramFileChanged();
    /**
     * @brief msgBoxSignal                      通知 打开消息框
     */
    void msgBoxSignal(int type,QString title,QString text);

    void setProgramRunLineSignal(int line);

    /**
     * @brief clearCurrentProductivitySignal      清除当前产量槽函数
     */
    void clearCurrentProductivitySignal();

    /**
     * @brief clearAccumulateProductivitySignal   清除累计产量槽函数
     */
    void clearAccumulateProductivitySignal();

public slots:
    /**
     * @brief clearCurrentProductivitySlot      清除当前产量槽函数
     */
    void clearCurrentProductivitySlot();

    /**
     * @brief clearAccumulateProductivitySlot   清除累计产量槽函数
     */
    void clearAccumulateProductivitySlot();

    /**
     * @brief forcePutDownMaterialSlot  强制放料槽函数
     */
    void forcePutDownMaterialSlot();

    /**
     * @brief forceFetchMaterialSlot    强制取料槽函数
     */
    void forceFetchMaterialSlot();
    /**
     * @brief setCurrentSelectRowSlot   设置当前行号(单击,以此获取对应行的内容)
     */
    void setCurrentSelectRowSlot();

    /**
     * @brief rightFunMoveToPointSlot   右侧工具栏 移动到点
     * @param type
     */
    void rightFunMoveToPointSlot(int type);
    void rightFunMoveStopSlot();

    /**
     * @brief setStartRunRowSlot        设置运行开始的行号(双击)
     */
    void setStartRunRowSlot(int line);

    /**
     * @brief updateDataAndView         接收middle的定时器,刷新数据
     */
    void updateDataAndView();

    void changeLanguageSlot(int language);

    void changeEditLanguageSlot(int language);
private:
    void monitorRobotPictureChange();

private:
    QTranslator translator;

    /**
     * @brief editLanguage              缓存显示语言
     */
    int editLanguage;

    RunView *runView;
    GlobalData *globalData;
    GlobalData *ioData;
    MoveOperation *moveOperation;
    ProgramLanguageTranslate *programLanguageTranslate;

    int currentPointNumber;
    int currentPointType;               //P 0 ; PR 1
    CommunicateNormalDelegate *communicateNormal;
};

#endif // RUNDELEGATE_H
